package main

import (
	"encoding/json"
	"fmt"
	"io"
	"log"
	"strings"
)

type User14 struct {
	UserName interface{} `json:"username"`
	Password string      `json:"password"`
}

var jsonString14 string = `{
    "email":"rsj217@gmail.com",
    "password":"123",
    "money":100.5
}`

func Decode14(r io.Reader) (u *User14, err error) {
	u = new(User14)
	if err = json.NewDecoder(r).Decode(u); err != nil {
		return
	}
	switch t := u.UserName.(type) {
	case string:
		u.UserName = t
	case float64:
		u.UserName = int64(t)
	}
	return
}

func main() {
	user, err := Decode14(strings.NewReader(jsonString14))
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("%#v\n", user)
}
